﻿using System.Collections.Generic;
using System.Web.Mvc;
using WD.Db.Contract;
using WD.Db.Contract.Model;
using WD.Framework.Contract;
using WD.Web.MVC.Common;

namespace WD.Web.MVC.Areas.BaseArea.Controllers
{
    public class Base_OperateLogController : AdminControllerBase
    {
        //
        // GET: /BaseArea/Base_OperateLog/

        public ActionResult Index(BaseRequest request)
        {
			var result = Base_OperateLogService.GetBase_OperateLogList(request);
            return View(result);
        }


        //
        // GET: /BaseArea/Base_OperateLog/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /BaseArea/Base_OperateLog/Create

        public ActionResult Create()
        {
            var model = new Base_OperateLog();
            return View("Create", model);
        }

        //
        // POST: /BaseArea/Base_OperateLog/Create

        [HttpPost]
        public string Create(FormCollection collection)
        {
            var ajax = new AjaxResult();
            var model = new Base_OperateLog();
            TryUpdateModel(model);
            try
            {
                Base_OperateLogService.SaveBase_OperateLog(model, LoginInfo.LoginId);
            }
            catch (BusinessException e)
            {
                return ajax.Err(e.Message);
            }
            return ajax.Suc("新增信息成功!");
        }

        //
        // GET: /BaseArea/Base_OperateLog/Edit/5

        public ActionResult Edit(int id)
        {
            var model = Base_OperateLogService.GetBase_OperateLog(id);
            return View("Edit", model);
        }

        //
        // POST: /BaseArea/Base_OperateLog/Edit/5

        [HttpPost]
        public string Edit(int id, FormCollection collection)
        {
            var ajax = new AjaxResult();
            var model = Base_OperateLogService.GetBase_OperateLog(id);
            TryUpdateModel(model);
            Base_OperateLogService.SaveBase_OperateLog(model, LoginInfo.LoginId);
            return ajax.Suc("信息修改成功!");
        }

        //
        // GET: /BaseArea/Base_OperateLog/Delete/5

        [HttpPost]
        public string Deleted(List<int> ids)
        {
            var ajax = new AjaxResult();
            try
            {
                Base_OperateLogService.DeleteBase_OperateLog(ids, LoginInfo.LoginId);
            }
            catch (BusinessException e)
            {
                return ajax.Err(e.Message);
            }

            return ajax.Suc("信息已成功删除!");
        }
    }
}
